<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
	
	// run session start
	public function _initSession() {
		Zend_Session::start();
	}
	
	// config language for applicaion
	public function _initLocale() {
		$locale = new Zend_Locale('vi_VN');
		Zend_Registry::set('Zend_Locale', $locale);   // config again for class Zend_Locale
		return $locale;
	}
	
	// config again database
	public function _initDb() {
		$optionResource = $this->getOption('resources');
		$dbOption      	= $optionResource['db'];
		$dbOption['params']['username'] = 'root';
		$dbOption['params']['password'] = '';
		$dbOption['params']['dbname']   = 'travel';
		
		$adapter = $dbOption['adapter'];
		$config  = $dbOption['params'];
		
		$db      = Zend_Db::factory($adapter, $config);
		
		// set type resule and font unicode
		
		$db->setFetchMode(Zend_Db::FETCH_ASSOC);   // result is an array
		$db->query("SET NAMES 'utf8'");
		$db->query("SET CHARACTER SET 'utf8'");
		
		Zend_Registry::set('connectDb', $db);
		Zend_Db_Table::setDefaultAdapter($db);
		return $db;
	}
	
	// config frontController
	public function _initFrontcontroller() {
		$front = Zend_Controller_Front::getInstance();
		$front->addModuleDirectory(APPLICATION_PATH . '/modules');
		$front->setDefaultModule('default');
		
		// add some plugin 
		
		return $front;
	}
	
}